package com.tourism.website.login.mapper;

import com.tourism.website.login.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {
    @Select("select * from user where user_name=#{username}")
    User findByUserName(String username);

    @Insert("insert into user(user_name, nick_name ,password, login_date, update_time,avatar) " +
            "values(#{username}, #{nickname} ,#{password}, now(), now(),#{avatar})")
    int register(String username,String nickname,String password,String avatar);
    @Insert("insert into user_role(role_id,username,user_id) values (#{role_id},#{username},#{userId})")
    boolean insertRoleId(int role_id,String username,Integer userId);
    @Select("select role_id from user_role where username=#{username}")
    Integer findRole(String username);
}
